#ifndef LEAMERRORSHH
#define LEAMERRORSHH
#include "errors.hh"
#include "leam-typedefs.hh"

namespace leam
{

    class LeamUserError : public licada::LicadaError
    {
	licada::TDataVector errorData;
    public:
	LeamUserError( const std::string& st, const licada::TDataVector& _errorData )
	    : licada::LicadaError( st ), errorData( _errorData ){}
	LeamUserError( const std::string& st )
	    :licada::LicadaError( st ) {}
	LeamUserError( const licada::TDataVector& _errorData )
	    : licada::LicadaError(), errorData( _errorData ){}
	virtual ~LeamUserError() throw() {}
	const licada::TDataVector& getErrorData() const { return errorData; }
    };


    class LeamError : public licada::LicadaError
    {
    public:
	LeamError(){}
	virtual ~LeamError() throw () {}
    };

    class LeamVersionMismatch : public LeamError
    {
	licada::uint16 version;
    public:
	LeamVersionMismatch( licada::uint16 _version ) : version( _version ){}
	virtual ~LeamVersionMismatch() throw(){}
	virtual licada::uint16 getVersion() const { return version; }
    };

    class LeamReadError : public LeamError
    {
    public:
	LeamReadError() {}
	virtual ~LeamReadError() throw(){}
    };

    class LeamWriteError : public LeamError
    {
    public:
	LeamWriteError() {}
	virtual ~LeamWriteError() throw(){}
    };
    
    class UnrecognizedMessageType : public LeamError
    {
	TType type;
    public:
	UnrecognizedMessageType( TType _t ) : type (_t){}
	virtual ~UnrecognizedMessageType() throw(){}
	virtual TType getType() const { return type; } 
    };
    
    class LeamStreamLengthError : public LeamError
    {
	TLength length;
	TLength request;
    public:
	LeamStreamLengthError( licada::uint32 _len, licada::uint32 _request )
	    : length( _len ), request( _request ) {}
	virtual ~LeamStreamLengthError() throw(){}
	//Current length
	TLength getLength() { return length; }
	//Request length
	TLength getRequest() { return request; }
    };
    
    class LeamDataStreamOverRead : public LeamStreamLengthError
    {
    public:
	LeamDataStreamOverRead( TLength _len, TLength _request ) : 
	    LeamStreamLengthError( _len, _request ) {}
    };
    
    class LeamDataStreamOverWrite : public LeamStreamLengthError
    {
    public:
	LeamDataStreamOverWrite( TLength _len, TLength _request ) : 
	    LeamStreamLengthError( _len, _request ) {}
    };
}
#endif
